import request from '@/utils/request'

export function getChatHistoryList(params={}) {
  return request({
    url: '/api/chat/history/list',
    method: 'post',
    data: params,
    isQuery: true,
    timeout: 2000
  })
}

export function getAIChatDetail(data) {
  return request({
    isLoading: true,
    url: '/api/chat/getAIChatDetail',
    method: 'post',
    data:data,
    timeout: 20000,
    isQuery: true,
  })
}

// 获取最后一次会话以及会话记录
export function getLastChat() {
  return request({
    isLoading: true,
    url: '/api/chat/getLastChat',
    method: 'get',
    timeout: 20000,
    isQuery: true,
  })
}


// 删除会话
export function deleteChat(ids) {
  return request({
    isLoading: true,
    url: '/api/chat/delete',
    method: 'delete',
    data: {
      ids: ids
    },
    timeout: 30000
  })
}


// 新增消息
export function addMessage(data) {
  return request({
    isLoading: false,
    url: '/api/chat/message/add',
    method: 'put',
    data: data,
    timeout: 2000
  })
}

// 发送消息
export function chatSendMessage(data) {
  return request({
    isLoading: false,
    url: '/api/chat/sendMessage',
    method: 'post',
    data: data,
    timeout: 3600000
  })
}

// 删除消息
export function deleteMessage(id) {
  return request({
    isLoading: true,
    url: '/api/chat/message/delete',
    method: 'delete',
    data: {
      id: id
    },
    timeout: 3600000
  })
}

export function changeChatAiAgent(data) {
  return request({
    isLoading: true,
    url: '/api/chat/change_chat_ai_agent',
    method: 'put',
    data: data,
    timeout: 2000
  })
}
